package com.sitech.webapp.listener;



import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sitech.BaseConst;


import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * <p>
 * StartupListener class used to initialize and database settings and populate
 * any application-wide drop-downs. <p/>
 * <p>
 * Keep in mind that this listener is executed outside of
 * OpenSessionInViewFilter, so if you're using Hibernate you'll have to
 * explicitly initialize all loaded data at the GenericDao or service level to
 * avoid LazyInitializationException. Hibernate.initialize() works well for
 * doing this.
 * 
 * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
 */
public class WebfolderListener implements ServletContextListener
{
	private static final Log log = LogFactory.getLog(WebfolderListener.class);

	
	public void contextInitialized(ServletContextEvent event)
	{
		String webRootFolder = event.getServletContext().getRealPath("/");
		BaseConst.WEBROOT_PATH = webRootFolder;
		log.debug("WEBROOT PATH IS "  + webRootFolder);
	}

	/**
	 * Shutdown servlet context (currently a no-op method).
	 * 
	 * @param servletContextEvent
	 *            The servlet context event
	 */
	public void contextDestroyed(ServletContextEvent servletContextEvent)
	{

	}
}
